package org.realman.sprites{
	import flash.display.Graphics;
	import flash.display.Sprite;
	
	public class RealMan extends Sprite{
		
		public var vx:Number = 0;
		
		public var vy:Number = 0;
		
		public var size:Number = 10;
		
		public function RealMan(size:Number = 10){
			super();
			
			this.size = size;
			init();
		}
		
		private function init():void{
			var g:Graphics = this.graphics;
			g.lineStyle(1, 0xFF0000);
			g.beginFill(0xFFFFFF);
			g.moveTo(-size/2, -size/2);
			g.drawRect(-size/2, -size/2, size, size);
			g.endFill();
		}
		
		public function move():void{
			var distX:Number = x + vx;
			var distY:Number = y + vy;
			if(distX - size < 0)
				distX = size;
			else if(distX + size > stage.stageWidth)
				distX = stage.stageWidth - size;
			
			if(distY - size < 0)
				distY = size;
			else if(distY + size > stage.stageHeight)
				distY = stage.stageHeight - size;
			x = distX;
			y = distY;
		}
	}
}